* reset frames
frame reset

* Open data and set background scheme
use  "INSERTPATH/data_S2.dta", clear // Remember to update file directory ("INSERTPATH")
cd "INSERTPATH" // Remember to update file directory ("INSERTPATH")
set scheme plotplain

* make & rescale variables
gen support_inparty =  inparty_affect/10 
gen support_outparty = outparty_affect/10
gen aff_pol = inparty_affect-outparty_affect
gen affective_polarization = (aff_pol+10)/20



* Fig 2, S2:
frame rename default data

qui reg vote_outparty i.D i.pid if condition!=2, rob 			// Misinformation
mat A1 = r(table)
qui reg vote_outparty i.D i.pid if condition!=1, rob			// Gerrymandering
mat A2 = r(table)

qui reg support_inparty i.D i.pid if condition!=2, rob		
mat B1 = r(table)
qui reg support_inparty i.D i.pid if condition!=1, rob		
mat B2 = r(table)

qui reg support_outparty i.D i.pid if condition!=2, rob
mat C1 = r(table)
qui reg support_outparty i.D i.pid if condition!=1, rob
mat C2 = r(table)

qui reg affective_polarization i.D i.pid if condition!=2, rob
mat D1 = r(table)
qui reg affective_polarization i.D i.pid if condition!=1, rob
mat D2 = r(table)

mat H = 0,.86,A1[1,2],A1[5,2],A1[6,2],0\		///
		0,.84,A2[1,2],A2[5,2],A2[6,2],1\		///
		1,.81,B1[1,2],B1[5,2],B1[6,2],0\ 	///
		1,.79,B2[1,2],B2[5,2],B2[6,2],1\	///
		2,.76,C1[1,2],C1[5,2],C1[6,2],0\ 	///
		2,.74,C2[1,2],C2[5,2],C2[6,2],1\ 	///
		3,.71,D1[1,2],D1[5,2],D1[6,2],0\ 	///
		3,.69,D2[1,2],D2[5,2],D2[6,2],1
		

		
mat list H	

* make plot: 
frame create plot1
cwf plot1		
svmat H
rename H1 outcome
rename H2 Ypos
rename H3 b
rename H4 ll
rename H5 ul
rename H6 condition							// 0 = misinformation, 1 = gerrymandering	

tw ///
	(rspike ll ul Ypos, horizontal lcolor(black)) ///
	(scatter Ypos b if condition==0, msym(O) mc(black) msize(med) mlabel(b) mlabformat(%5.2fc) mlabposition(12) mlabsize(vsmall)) ///
	(scatter Ypos b if condition==1, msym(O) mc(black) mfcolor(white) msize(med) mlabel(b) mlabformat(%5.2fc) mlabposition(6) mlabsize(vsmall)) ///
	, yscale(range(.68 .87) lc(none)) ytit("") ///
	ylab(.85 "Out-Party Voting" .8 "In-Party Affect" .75 "Out-Party Affect" .7 "Affective Polarization", notick glpattern(solid) glcolor(gs14%50)) ///
	xtit("Treatment Effect Estimate", size(small)) xscale(range(-.35 .25) lc(none)) xlab(-.3 -.2 -.1 0 .1 .2, notick glpattern(solid) glcolor(gs14%50)) xline(0) ///
	legend(order(2 "Misinformation" 3 "Gerrymandering" )) plotregion(lcolor(black) lwidth(medium)) ///
	title("In-Party Cheating", size(small) justification(left) pos(11)) ///
	name(S2_affect, replace)
	

graph display, xsize(5) ysize(2.1) scale(2.2)	

graph export "S2_Fig2.pdf", as(pdf) replace	
